const path = require('path'); // nodejs自带的处理路径的库
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: { // 项目入口
    index: './src/index.js',
    print: './src/print.js'
  },
  output: { // 输出
    filename: '[name].bundle.js', // 文件名
    path: path.resolve(__dirname, './dist'), // 需绝对路径
  },
  optimization: {
    splitChunks: {
      chunks: 'all'
    }
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'] // loader 的执行顺序是：从后往前
      }, {
        test: /\.less$/,
        use: ['style-loader', 'css-loader', 'less-loader']
      }, {
        test: /\.(png|jpg|svg)$/,
        type: 'asset/resource'
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: '管理输出',
    }),
  ]
}